# -*- coding: utf-8 -*-
#
# Author:: hanjunfeng
# Date:: 2023/4/18

import os
import shutil

project_path = os.getcwd()
hooks_path_source = os.path.join(project_path, ".git_hooks")
hooks_path_target = os.path.join(project_path, ".git", "hooks")

files = os.listdir(hooks_path_source)

for file_name in files:
    source_file = os.path.join(hooks_path_source, file_name)
    target_file = os.path.join(hooks_path_target, file_name)

    shutil.copy2(source_file, target_file)

os.popen(f"chmod +x {os.path.join(hooks_path_target, 'pre-commit')}")
